<?php

namespace app\admin\controller;

use app\common\controller\Backend;

/**
 * 
 *
 * @icon fa fa-circle-o
 */
class LihuaArticles extends Backend
{
    
    /**
     * LihuaArticles模型对象
     * @var \app\admin\model\LihuaArticles
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\LihuaArticles;
        $this->view->assign("tjdataList", $this->model->getTjdataList());
    }
    
    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */

    
    /**
     * 分享单页选择活动
     *
     * @internal
     */
    public function sel()
    {
        $list = [];
        if ($this->request->isPost()) {
            
            $where = [];
            if($this->request->request("keyValue")){
                $where['id'] = $this->request->request("keyValue");
            }
            if($this->auth->city_id > 0){
                $where['city_id'] = $this->auth->city_id;
            }else{
                $city_id = (int)$this->request->request('city_id', '0');
                if($city_id!=0){
                    $where['city_id'] = $city_id;
                }
            }
            $list = $this->model
                ->where($where)
                ->select();
        }
        return json(['list' => $list, 'total' => count($list)]);
    }

}
